package org.squareland.entities;

public class Entity {
	public Entity(int height, int width) {
		this.height = height;
		this.width = width;	
		pixels = new int[height][width];
		beartime = System.currentTimeMillis();
		lifetime = LIFETIME_INFTY;
	}

	public Entity(int height, int width, int x, int y) {
		this(height,width);
		this.x = x;
		this.y = y;
	}
	
	/** Copy constructor */
	public Entity(Entity entity) {
		x = entity.x;
		y = entity.y;
		speedX = entity.speedX;
		speedY = entity.speedY;
		lifetime = entity.lifetime;
		beartime = entity.beartime;
		height = entity.height;
		width = entity.width;
		pixels = entity.pixels;		
	}
	
	
	public int at(int row, int col) {
		return pixels[row][col];
	}

	/** Copy of entity collided with */
	public void collisionCollpack(Entity entity, long mills) {
	}
	
	public void setPixel(int row, int col, int color) {
		pixels[row][col] = color;
	}
	
	public int getHeight() {
		return height;
	}
	
	public int getWidth() {
		return width;
	}
	
	public boolean intersect(Entity e) {
		boolean intersectX = (e.x <= x && x <= e.x + e.width)  || (x <= e.x && e.x <= x + width);
		boolean intersectY = (e.y <= y && y <= e.y + e.height) || (y <= e.y && e.y <= y + height);
		return (intersectX && intersectY);
	}
		
	public float x;
	public float y;
	public float speedX;
	public float speedY;
	public long lifetime;
	public long beartime;
	public int height;
	public int width;
	public int pixels[][];
	public static final long LIFETIME_INFTY = -1;
}
